<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>用户登录</title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" href="css/css.css" />
	</head>

	<body>
		<div class="mui-content login_con">
			<div class="login_conbox">
				<form id='login-form' class="login_formbox">
					<p class="bt">登录账户</p>
					<div class="mui-input-row">
						<label><span class="iconfont icon-shouji-copy"></span></label>
						<input id='phone' type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
					</div>
					<div class="mui-input-row">
						<label><span class="iconfont icon-mima"></span></label>
						<input id='pwd' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
					</div>
				</form>
				<div class="link_area clearfix">
					<a id='reg' class="flogin" href="javascript:;">注 册</a>
					<a id='forgetPassword' href="javascript:;">忘记密码？</a>
				</div>
				<div class="mui-content-padded">
					<p><button id='btn' class="login_btn">登 录</button></p>
				</div>
			</div>
		</div>
	</body>

</html>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/layer/layer.min.js"></script>
<script type="text/javascript">
	//登录
//	QC.Login({
//		btnId: "qqLoginBtn" //插入按钮的节点id
//	});
	$('#btn').click(function() {
		var phone = $("#phone").val();
		var pwd = $("#pwd").val();
		if(phone == '') {
			layer.msg('手机号码不能为空');
			return;
		}
		var reg = /^1[3|4|5|7|8][0-9]{9}$/; //验证规则
		if(!reg.test(phone)) {
			layer.msg('手机号码格式不正确');
			onoff = true;
			return;
		}
		if(pwd.trim() == '') {
			layer.msg('登录密码不能为空');
			return;
		}
		//写入数据库
		$.ajax({
			//请求的url
			//注意，如果我们使用路由器的情况下，我们需要设置一下本地服务器的ip地址
			url: APP.api_url + 'User/login',
			//请求的过程中传递过去的参数 json
			data: {
				mobile: phone,
				pwd: pwd
			},
			dataType:'jsonp',
			//成功了的回调，并且带有返回值
			success: function(data) {
				if(data.code == 200) {
				layer.msg(data.data, {icon: 1,time:1500,shade: 0.1}, function(index){
					localStorage.setItem('member', JSON.stringify(data.member));
                    window.location.href=APP.web_root+"member/member_index.html";
               });
				}else{
					layer.msg(data.data, {icon: 1,time:1500,shade: 0.1}, function(index){
                    window.location.href="login.html";
               });
				}
				
			}
		})
	});

	//忘记密码
	$("#forgetPassword").click(function() {
		location.href = "return_pwd.html";
	});
	//快速登录
	$("#fast_login").click(function() {
		location.href = "login_fast.html";
	});
	//注册
	$("#reg").click(function() {
		location.href = "regist.html";
	});
</script>